package main

import "fmt"

func fn1() int {
	x := 5
	defer func() {
		x++
	}()

	return x
}

func fn2() (x int) {
	defer func() {
		x++
	}()

	return 5
}

func fn3() (y int) {
	x := 5
	defer func() {
		x++
	}()

	return x
}

func fn4() (x int) {
	defer func(x int) {
		fmt.Println(x)
		x++
	}(x)

	fmt.Println("a=", x)
	return 5
}

func main() {
	//fmt.Println(fn1())
	//fmt.Println(fn2())
	//fmt.Println(fn3())
	fmt.Println(fn4())
}
